﻿using System;

namespace GMS.Utils
{
    public static class EntityHelper<T> where T : class, new()
    {
        public static void SetComm(T t)
        {
            var properties = t.GetType().GetProperties();
            foreach (var propertyInfo in properties)
            {
                if (propertyInfo.Name == "CreateId")
                {
                    propertyInfo.SetValue(t, Guid.Parse("980CB416-0C28-492B-A6E5-FDBBDC55BA83"));
                }
                if (propertyInfo.Name == "CreateBy")
                {
                    propertyInfo.SetValue(t, "supper");
                }
                if (propertyInfo.Name == "CreateTime")
                {
                    propertyInfo.SetValue(t, DateTime.Now);
                }
                if (propertyInfo.Name == "ModifyId")
                {
                    propertyInfo.SetValue(t, null);
                }
                if (propertyInfo.Name == "ModifyBy")
                {
                    propertyInfo.SetValue(t, null);
                }
                if (propertyInfo.Name == "ModifyTime")
                {
                    propertyInfo.SetValue(t, null);
                }
            }
        }
    }
}